package come.bjpowernode.javase.io;

import come.bjpowernode.javase.bean.Student;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

/*
反序列化
 */
public class ObjectInputStreamTest01 {
    public static void main(String[] args)throws Exception {
       ObjectInputStream  ois = new ObjectInputStream(
               new FileInputStream("students"));
       //开始反序列化
        Object obj1 = ois.readObject();
        Object obj2 = ois.readObject();

        Student student = (Student) obj1;
        System.out.println(student.getName());

        //反序列化回来是一个学生对象，会调用学生对象的toString
        System.out.println(obj1);
        System.out.println(obj2);


        ois.close();
    }
}
